package com.esri.ags.symbol
{
    import com.esri.ags.*;
    import com.esri.ags.controls.infoClasses.*;
    import com.esri.ags.geometry.*;
    import flash.display.*;
    import mx.core.*;

    public class InfoSymbol extends Symbol
    {
        private var m_infoRenderer:IFactory;
        private var m_infoPlacement:String;

        public function InfoSymbol()
        {
            m_infoRenderer = new InfoDataGridFactory();
            return;
        }// end function

        public function set infoRenderer(MapPoint:IFactory) : void
        {
            if (MapPoint == null)
            {
                m_infoRenderer = new InfoDataGridFactory();
            }
            else
            {
                m_infoRenderer = MapPoint;
            }// end else if
            dispatchEventChange();
            return;
        }// end function

        override public function draw(Map:Sprite, graphics:Geometry, clear:Object, removeAllChildren:Map) : void
        {
            var _loc_5:InfoSymbolContainer;
            var _loc_6:Object;
            var _loc_7:int;
            var _loc_8:DisplayObject;
            if (graphics is MapPoint)
            {
                if (Map.numChildren == 0)
                {
                    if (infoRenderer)
                    {
                        _loc_5 = new InfoSymbolContainer();
                        _loc_6 = infoRenderer.newInstance();
                        if (_loc_6 is DisplayObject)
                        {
                            _loc_5.addChild(DisplayObject(_loc_6));
                        }// end if
                        Map.addChild(_loc_5);
                    }// end if
                }
                else
                {
                    _loc_7 = 0;
                    while (_loc_7++ < Map.numChildren)
                    {
                        // label
                        _loc_8 = Map.getChildAt(_loc_7);
                        if (_loc_8 is InfoSymbolContainer)
                        {
                            _loc_5 = InfoSymbolContainer(_loc_8);
                            break;
                        }// end if
                    }// end while
                }// end else if
                if (_loc_5)
                {
                    if (m_infoPlacement)
                    {
                        _loc_5.setStyle(InfoContainer.INFO_PLACEMENT, m_infoPlacement);
                    }// end if
                    _loc_5.data = clear;
                    drawMapPoint(removeAllChildren, Map, graphics as MapPoint, _loc_5);
                }// end if
            }// end if
            return;
        }// end function

        override public function clear(Map:Sprite) : void
        {
            Map.graphics.clear();
            return;
        }// end function

        public function set infoPlacement(MapPoint:String) : void
        {
            if (MapPoint != m_infoPlacement)
            {
                m_infoPlacement = MapPoint;
                dispatchEventChange();
            }// end if
            return;
        }// end function

        public function get infoRenderer() : IFactory
        {
            return m_infoRenderer;
        }// end function

        public function get infoPlacement() : String
        {
            return m_infoPlacement;
        }// end function

        private function drawMapPoint(removeAllChildren:Map, Map:Sprite, :MapPoint, :InfoSymbolContainer) : void
        {
            clear(Map);
            var _loc_5:* = toScreenX(removeAllChildren, x);
            var _loc_6:* = toScreenY(removeAllChildren, y);
            anchorX = _loc_5;
            anchorY = _loc_6;
            setActualSize(measuredWidth, measuredHeight);
            visible = true;
            return;
        }// end function

        override public function destroy(Map:Sprite) : void
        {
            removeAllChildren(Map);
            Map.x = 0;
            Map.y = 0;
            return;
        }// end function

    }
}
